package net.xdclass.test;

import lombok.extern.slf4j.Slf4j;
import net.xdclass.LinkApplication;
import net.xdclass.compoent.ShortLinkComponent;
import net.xdclass.enums.DomainTypeEnum;
import net.xdclass.manager.DomainManager;
import net.xdclass.manager.GroupCodeMappingManager;
import net.xdclass.manager.ShortLinkManager;
import net.xdclass.model.DomainDO;
import net.xdclass.model.ShortLinkDO;
import net.xdclass.utils.CommonUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;
import java.util.Random;

/**
 * @author ：zhouyang
 * @date ：Created in 2022/5/10 17:19
 * @modified By：
 * @version: $
 */
@RunWith(SpringRunner.class)
@Slf4j
@SpringBootTest(classes = LinkApplication.class)
public class testt {
    @Autowired
    private ShortLinkComponent shortLinkComponent;
    @Autowired
    private ShortLinkManager shortLinkManager;
    @Autowired
    private DomainManager domainManager;

    @Test
    public void testtt() {
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            int i1 = random.nextInt(10);
            int i2 = random.nextInt(10000);
            int i3 = random.nextInt(10000000);
            String originaUrl = i1 + "xdclass" + i2 + ".net" + i3;
             String shortLinkCode = shortLinkComponent.createShortLinkCode(originaUrl);

            ShortLinkDO shortLinkDO = new ShortLinkDO();
            shortLinkDO.setCode(shortLinkCode);
            shortLinkDO.setAccountNo(Long.valueOf(random.nextInt(1000000000)));
            shortLinkDO.setSign(CommonUtil.MD5(originaUrl));
            shortLinkDO.setDel(0);
            shortLinkManager.add(shortLinkDO);

        }
    }


    @Test
    public void find(){
         String name = DomainTypeEnum.CUSTOM.name();
        log.info(name);
    }
}
